/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "SEGGER_RTT.h"
#include "mbrtu_master.h"
#include "uart_bsp.h"
//#include "usb_device.h"
//#include "usbd_cdc_if.h"
//#include "usbd_core.h"
//#include "usbd_cdc.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define CAN2_POWER_Pin GPIO_PIN_13
#define CAN2_POWER_GPIO_Port GPIOC
#define CAN1_POWER_Pin GPIO_PIN_14
#define CAN1_POWER_GPIO_Port GPIOC
#define POWER_5V_EN_Pin GPIO_PIN_15
#define POWER_5V_EN_GPIO_Port GPIOC
#define ACC_CS_Pin GPIO_PIN_0
#define ACC_CS_GPIO_Port GPIOC
#define GYRO_CS_Pin GPIO_PIN_3
#define GYRO_CS_GPIO_Port GPIOC

/* USER CODE BEGIN Private defines */
//#define __USB_DEBUG__    //ע�����رյ��Դ�ӡ
#ifdef  __USB_DEBUG__  
#define USB_LOG_INFO(format,...)	{usb_printf(format,##__VA_ARGS__);}  
#else
#define USB_LOG_INFO(format,...)
#endif

#define __RTT_DEBUG__    //ע�����رյ��Դ�ӡ
#ifdef  __RTT_DEBUG__  
#define LOG_INFO(a, ...)                   \
    do                                     \
    {                                      \
        SEGGER_RTT_SetTerminal(a);         \
        SEGGER_RTT_printf(0, __VA_ARGS__); \
    } while (0)
#else
#define LOG_INFO(a,...)
#endif 


//DWT????
#define  DEM_CR_TRCENA               (1 << 24)
#define  DWT_CR_CYCCNTENA            (1 <<  0)
#define  DWT_CYCCNT  *(volatile unsigned int *)0xE0001004
#define  DWT_CR      *(volatile unsigned int *)0xE0001000
#define  DEM_CR      *(volatile unsigned int *)0xE000EDFC
#define  DBGMCU_CR   *(volatile unsigned int *)0xE0042004


// ??DWT????????
// //DWT????
// DEM_CR         |= (unsigned int)DEM_CR_TRCENA;   
// DWT_CYCCNT      = (unsigned int)0u;
// DWT_CR         |= (unsigned int)DWT_CR_CYCCNTENA;
// time1 = DWT_CYCCNT;
// time2 = DWT_CYCCNT;
// sprintf(time_,"time:%fs\r\n",(float)(time2-time1)/SystemCoreClock);
// LOG_INFO(0,time_);

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
